﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using nanoCMS.Core.Concrete;
using nanoCMS.Core.WebProviders;
using nanoCMS.Core.WebUI.Models.ViewModels;

namespace nanoCMS.Core.WebUI.Models {
	public class NavigationService {
		private readonly WorldContext _worldContext;
		private NavigationProvider navigationProvider;


		public NavigationService(WorldContext worldContext)
		{
			_worldContext = worldContext;
			navigationProvider = new NavigationProvider(worldContext);
		}

		public List<NavigationItemVM>  GetNavigation(int navigationId)
		{
			return navigationProvider.GetNavigationItems(navigationId).Select(NavigationItemVMFactory).ToList();
		}

		public static NavigationItemVM NavigationItemVMFactory(TenantNavigationItem model)
		{
			return  new NavigationItemVM
			        	{
			        		IDNavigationItem =  model.IDNavigationItem,
							NavigationID = model.NavigationID,
							IsInner = model.IsInner,
							Order = model.Order,
							Text = model.Text,
							Title = model.Title,
							Url = model.Url
			        	};
		}
	}
}
